﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using System.IO;
using Icinetic.FeedCategorySample.Services;
using Icinetic.FeedCategorySample.ViewModel;
using System.Threading.Tasks;
using Windows.UI;
using Icinetic.FeedCategorySample.Entities;
using Icinetic.FeedCategorySample.Services.Repositories;

namespace FeedCategorySample.Test
{
    [TestClass]
    public class ArticlePageViewModelTest
    {
        private string dbPath = BaseRepository.DbPath;

        [TestInitialize]
        public void TestInitialize()
        {
            BaseRepository.DbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "FeedCategorySampleTestDB.db");
            BaseRepository.Initialize();
        }

        [TestCleanup]
        public void TestCleanup()
        {
            BaseRepository.DbPath = dbPath;
        }

        [TestMethod]
        public void LoadFeedItemTest()
        {
            RssItem rssItem = DataHelper.NewRssItem();
            RssItemRepository rssItemService = new RssItemRepository();
            rssItemService.Add(rssItem);

            ArticlePageViewModel model = new ArticlePageViewModel();
            model.LoadFeedItem(rssItem);

            Assert.IsNotNull(model.Item);
            Assert.IsTrue(model.Item.IsRead);
        }
    }
}
